home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / MonitorDoubler / Source / Documents / MultiMonitorDoc.cp next >
Encoding:
Text File  |  2000-06-23  |  3.4 KB  |  137 lines

  1. #include "MultiMonitorDoc.h"
  2.  
  3. #include <PP_DebugMacros.h>
  4. #include <PP_KeyCodes.h>
  5.  
  6. #include <LFile.h>
  7. #include <LPlaceHolder.h>
  8. #include <LCheckBoxGroupBox.h>
  9. #include <LCheckBox.h>
  10. #include <LPrintout.h>
  11. #include <LString.h>
  12. #include <LSlider.h>
  13. #include <LWindow.h>
  14. #include <PP_Messages.h>
  15. #include <UMemoryMgr.h>
  16. #include <UResourceMgr.h>
  17. #include <UWindows.h>
  18.  
  19. #include <AERegistry.h>
  20.  
  21. #include "AppConstants.h"
  22. #include "MultiMonitorController.h"
  23.  
  24. const PaneIDT    kPaneID_Enable                = 'MMEn';
  25. const PaneIDT    kPaneID_Magnify                = 'Mgnf';
  26.  
  27. const MessageT    msg_Enable                    = 'MMEn';
  28. const MessageT    msg_Magnify                    = 'Mgnf';
  29.  
  30.  
  31. // ---------------------------------------------------------------------------------
  32. //    • MultiMonitorDoc                                        [public]
  33. // ---------------------------------------------------------------------------------
  34. //    Constructor
  35.  
  36. MultiMonitorDoc::MultiMonitorDoc(
  37.     LCommander *        inSuper)
  38.     : LSingleDoc(inSuper)
  39. {
  40.         // Create window for our document.
  41.     mWindow = LWindow::CreateWindow(PPob_TextWindow, this );
  42.     ValidateObject_(mWindow);
  43.     
  44.     LPane *     newPane;
  45.     
  46.     newPane = mWindow->FindPaneByID(kPaneID_Enable);
  47.     ValidateObject_(newPane);
  48.     static_cast<LCheckBoxGroupBox *>(newPane)->AddListener(this);
  49.  
  50.     newPane = mWindow->FindPaneByID(kPaneID_Magnify);
  51.     ValidateObject_(newPane);
  52.     static_cast<LCheckBox *>(newPane)->AddListener(this);
  53.  
  54.         // Make the window visible.
  55.     mWindow->Show();
  56. }
  57.  
  58.  
  59. // ---------------------------------------------------------------------------------
  60. //    • ~MultiMonitorDoc                                    [public, virtual]
  61. // ---------------------------------------------------------------------------------
  62. //    Destructor
  63.  
  64. MultiMonitorDoc::~MultiMonitorDoc()
  65. {
  66.     MultiMonitorController &    mmController = MultiMonitorController::GetInstance();
  67.  
  68.     // Disable the multi-monitor controller before
  69.     // going away.
  70.     mmController.Disable();
  71.  
  72.     TakeOffDuty();
  73. }
  74.  
  75.  
  76. // ---------------------------------------------------------------------------
  77. //    • FindCommandStatus                                    [public, virtual]
  78. // ---------------------------------------------------------------------------
  79. //    Override provided here for convenience.
  80.  
  81. void
  82. MultiMonitorDoc::FindCommandStatus(
  83.     CommandT        inCommand,
  84.     Boolean&        outEnabled,
  85.     Boolean&        outUsesMark,
  86.     UInt16&            outMark,
  87.     Str255            outName)
  88. {
  89.     LSingleDoc::FindCommandStatus(inCommand, outEnabled, outUsesMark, outMark, outName);    
  90. }
  91.  
  92.  
  93. // ---------------------------------------------------------------------------
  94. //    • ListenToMessage                                    [public, virtual]
  95. // ---------------------------------------------------------------------------
  96.  
  97. void
  98. MultiMonitorDoc::ListenToMessage(
  99.     MessageT        inMessage,
  100.     void*            ioParam)
  101. {
  102.     SInt32                        controlValue = *reinterpret_cast<SInt32 *>(ioParam);
  103.     MultiMonitorController &    mmController = MultiMonitorController::GetInstance();
  104.     
  105.     switch (inMessage)
  106.     {
  107.         case msg_Enable:
  108.             if (controlValue == 0)
  109.                 mmController.Disable();
  110.             else
  111.                 mmController.Enable();
  112.             break;
  113.         
  114.         case msg_Magnify:
  115.             mmController.EnableMagnify(controlValue);
  116.             break;
  117.     }
  118. }
  119.  
  120.  
  121. // ---------------------------------------------------------------------------
  122. //    • ObeyCommand                                        [public, virtual]
  123. // ---------------------------------------------------------------------------
  124. //    Override provided here for convenience.
  125.  
  126. Boolean
  127. MultiMonitorDoc::ObeyCommand(
  128.     CommandT        inCommand,
  129.     void*            ioParam)
  130. {
  131.     Boolean    cmdHandled = LSingleDoc::ObeyCommand(inCommand, ioParam);
  132.  
  133.     return cmdHandled;
  134. }
  135.  
  136.  
  137.